home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / mawk10.zip / FPE_TEST.BAT < prev    next >
DOS Batch File  |  1991-10-05  |  2KB  |  130 lines

  1. echo off
  2. rem  tests if mawk has been compiled to correctly handle
  3. rem  floating point exceptions
  4.  
  5. echo testing division by zero
  6. type fpetest1.awk
  7. mawk -f fpetest1.awk
  8. if errorlevel 128 goto :test1_128
  9. if errorlevel 3 goto :test1_3
  10. if errorlevel 2 goto :test1_2
  11. if errorlevel 1 goto :test1_1
  12. set ret1=0
  13. goto :test2
  14. :test1_128
  15. set ret1=128
  16. goto :test2
  17. :test1_3
  18. set ret1=3
  19. goto :test2
  20. :test1_2
  21. set ret1=2
  22. goto :test2
  23. :test1_1
  24. set ret1=1
  25.  
  26. :test2
  27. echo testing overflow
  28. type fpetest2.awk
  29. mawk -f fpetest2.awk
  30. if errorlevel 128 goto :test2_128
  31. if errorlevel 3 goto :test2_3
  32. if errorlevel 2 goto :test2_2
  33. if errorlevel 1 goto :test2_1
  34. set ret2=0
  35. goto :test3
  36. :test2_128
  37. set ret2=128
  38. goto :test3
  39. :test2_3
  40. set ret2=3
  41. goto :test3
  42. :test2_2
  43. set ret2=2
  44. goto :test3
  45. :test2_1
  46. set ret2=1
  47.  
  48. :test3
  49. echo testing domain error
  50. type fpetest3.awk
  51. mawk -f fpetest3.awk > temp$$
  52. if errorlevel 128 goto :test3_128
  53. if errorlevel 3 goto :test3_3
  54. if errorlevel 2 goto :test3_2
  55. if errorlevel 1 goto :test3_1
  56. set ret3=0
  57. goto :type3
  58. :test3_128
  59. set ret3=128
  60. goto :type3
  61. :test3_3
  62. set ret3=3
  63. goto :type3
  64. :test3_2
  65. set ret3=2
  66. goto :type3
  67. :test3_1
  68. set ret3=1
  69.  
  70. :type3
  71. type temp$$
  72.  
  73. rem  the returns should all be zero or all 1
  74.  
  75. echo *************************************
  76. echo return1 = %ret1%
  77. echo return2 = %ret2%
  78. echo return3 = %ret3%
  79.  
  80. set exception=0
  81. if %ret1% == 1 goto :okay1
  82. if %ret1% == 0 goto :okay1
  83. echo test1 failed
  84. set exception=1
  85. :okay1
  86. if %ret2% == 1 goto :okay2
  87. if %ret2% == 0 goto :okay2
  88. echo test2 failed
  89. set exception=1
  90. :okay2
  91. if %ret3% == 1 goto :okay3
  92. if %ret3% == 0 goto :okay3
  93. echo test3 failed
  94. set exception=1
  95. :okay3
  96.  
  97. if %exception% == 1 goto :done
  98.  
  99. set same=1
  100. if %ret1% == %ret2% goto :same12
  101. set same=0
  102. :same12
  103. if %ret2% == %ret3% goto :same23
  104. set same=0
  105. :same23
  106.  
  107. if %same% == 1 goto :same123
  108. echo results are not consistent
  109. echo return values should all be 0 if ignoring FPEs (e.g. with IEEE754)
  110. echo or all 1 if trapping FPEs
  111. goto :cleanup
  112.  
  113. :same123
  114. if %ret1% == 0 goto :allzero
  115. echo results consistent: trapping floating exceptions
  116. goto :cleanup
  117.  
  118. :allzero
  119. echo results consistent: ignoring floating exceptions
  120. grep -i nan temp$$ >NUL
  121. if not errorlevel 1 goto :cleanup
  122. echo but the library is not IEEE754 compatible
  123. echo test 3 failed
  124.  
  125. :cleanup
  126. del temp$$
  127.  
  128. :done
  129. exit %exception%
  130.